﻿@using testApp2.Models
@model testApp2.Models.User
@{
    ViewBag.Title = "Home Page";
}
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Language Exp</legend>
        @if (Model.Interests == null || Model.Interests.Count == 0)
        {
            <p>
                None</p>
        }
        else
        {
            <ul id="interestList" style="list-style-type: none">
                @if (Model.Interests != null)
                {
                    foreach (UserInterest interest in Model.Interests)
                    {
                        Html.RenderPartial("InterestEditor", interest);
                    }
                }
            </ul>
            <a id="addAnother" href="#">Add another</a>
        }
    </fieldset>
    <p>
        <input type="submit" value="Save" />
        <a href="/">Cancel</a>
    </p>
}

<script type="text/javascript">
    $(function () {
        $("#interestList").sortable();
        $("#addAnother").click(function () {
            $.get('/Home/InterestRow', function (template) {
                $("#interestList").append(template);
            });
        });
    });
</script>
